﻿#if UNITY_EDITOR
using UnityEngine;

namespace NodeCanvas.Editor.LevelEditor
{
    public class EventRectangleDrawer : EventDrawer
    {
        private static Color halfGreen = new Color( Color.green.r, Color.green.g, Color.green.b, 0.05f);
        
        protected void OnDrawGizmos()
        {
            var v1 = transform.position;
            v1.y = 0;
            transform.position = v1;
            var r1 = transform.rotation;
            r1.x = 0;
            r1.z = 0;
            transform.rotation = r1;
            var localScale = transform.localScale;
            var pos = transform.position;
            var rotation = transform.rotation;
            Vector3[] verts = new Vector3[]
            {
                rotation * new Vector3(-localScale.x, 0, -localScale.z) + pos,
                rotation * new Vector3(-localScale.x, 0, +localScale.z) + pos,
                rotation * new Vector3(+localScale.x, 0, +localScale.z) + pos,
                rotation * new Vector3(+localScale.x, 0, -localScale.z) + pos,
            };
            
#if UNITY_EDITOR
            UnityEditor.Handles.DrawSolidRectangleWithOutline(verts, halfGreen, Color.green);
#endif
        }
    }
}
#endif